<template>
  <div>
    <div class="title-msg">订单明细</div>

    <div class="option-site">
      <div class="back" @click="backClick">《返回</div>
      <div class="item title-code">
        订单编号:{{order_code}}
      </div>
      <div class="item"
           v-for="i in orderDetail">
        <span>商品名:{{i.name}}</span>
        <span>商品单价:￥{{i.goodsprice}}</span>
        <span>购买数:{{i.goodscount}}</span>
        <span>小计:￥{{i.price}}</span>
      </div>
      <div class="item">
        总消费:￥{{amount}}
      </div>
    </div>

  </div>
</template>

<script>
  import {getOrderDetail} from 'network/mix'
  export default {
    name: "OrderDetail",
    data() {
      return {
        order_code: '', // 订单编号
        amount: 0, // 订单总消费
        orderDetail: [], // 订单明细
      }
    },
    created() {
      this.order_code = this.$route.params.formData.code
      this.amount = this.$route.params.formData.amount
      // console.log(this.order_code);
    },
    mounted() {
      this.mGetOrderDetail()
    },
    methods: {
      backClick() {
        this.$router.push('/admin/order')
      },

      mGetOrderDetail() {
        getOrderDetail(this.order_code)
          .then(res => {
            this.orderDetail = res.orderList
            // console.log(this.orderDetail);
          })
          .catch(error => {
            console.log('获取订单明细失败！！！');
            console.log(error);
          })
      }
    }
  }
</script>

<style scoped>
  .title-msg {
    height: 60px;
    line-height: 60px;
    margin-left: 20px;
    margin-right: 20px;
    border-bottom-right-radius: 6px;
    border-bottom-left-radius: 6px;
    border: 1px solid #cdcdcd;

    text-align: center;
    font-size: 30px;

    background-color: white;
  }
  .option-site {
    position: relative;
    margin-top: 30px;
    margin-left: 20px;
    margin-right: 20px;
    height: 530px;

    border: 1px solid #cdcdcd;
    border-radius: 6px;
    background-color: #ebebeb;

    /*background-color: green;*/
  }
  .option-site .back {
    position: absolute;
    width: 50px;
    height: 25px;

    color: #919191;
    font-weight: bold;
    font-size: 16px;

    background-color: #fff;
    border-top-left-radius: 6px;
  }
  .option-site .back:hover {
    cursor: pointer;
    color: black;
    opacity: 0.75;
  }

  .item {
    /*margin-top: 0.5%;*/
    margin: auto;

    height: 50px;
    width: 60%;

    text-align: center;
    line-height: 50px;
    border: 1px solid #cdcdcd;

    /*background-color: yellow;*/
  }
  .item span {
    margin-right: 20px;
  }

  .title-code {
    margin: auto;

    width: 60%;
  }
</style>